package com.nuoniu.sibanyun.controller.erp;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.erp.ErpFile;
import com.nuoniu.sibanyun.service.erp.IErpFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 项目文件管理 前端控制器
 * </p>
 *
 * @author 小啊刚
 * @since 2021-10-26
 */
@RestController
@RequestMapping("/erp/file")
@Api(tags = "项目文件管理")
public class ErpFileController extends BaseController {

    @Autowired
    private IErpFileService fileService;

    @ApiOperation("获取列表")
    @GetMapping("getList")
    public HttpResult getList(Integer projectId, Integer type) {
        return HttpResult.ok(fileService.getList(projectId, type));
    }

    @ApiOperation("保存文件")
    @PostMapping("save")
    public HttpResult save(@RequestBody ErpFile file) {
        fileService.saveFile(file);
        return HttpResult.ok();
    }

    @ApiOperation("删除")
    @DeleteMapping("delete")
    public HttpResult delete(Long id) {
        fileService.removeById(id);
        return HttpResult.ok();
    }
}
